package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrdersMapper {
    void addOrder(Orders orders);

    Orders getByNumberAndUserId(String outTradeNo, Long userId);

    /**
     * 更新订单状态
     * @param orders
     */
    void updateOrder(Orders orders);


    Integer getOrdersCount(Integer status);

    /**
     * 订单搜索
     * @param dto
     * @return
     */
    Page<OrderVO> getOrders(OrdersPageQueryDTO dto);


    OrderVO getOrdersById(Long id);

    //历史订单分页查询
    Page<OrderVO> getOrderByPage(OrdersPageQueryDTO dto);
    /**
     * 派送订单
     * @param id
     */
    void deliveryOrder(Long id);

    /**
     * 派送订单
     * @param id
     */
    void completeOrder(Long id);

    List<Orders> getOrdersByTime(LocalDate begin, LocalDate end);

    /**
     * 获取待支付订单
     * @param status
     * @param time
     * @return
     */
    List<Orders> getOrdersUnpaid(Integer status, LocalDateTime time);

    /**
     * 支付成功后修改订单状态
     * @param orders
     */
    void updateUnpaidOrder(Orders orders);
}
